package com.key.win.business.meeting.ctrl;

import com.key.win.base.web.PageRequest;
import com.key.win.base.web.PageResult;
import com.key.win.base.web.Result;
import com.key.win.business.meeting.model.MtRecording;
import com.key.win.business.meeting.service.MtRecordingService;
import com.key.win.business.meeting.vo.MtRecordingVo;
import com.key.win.common.log.annotation.LogAnnotation;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/recording/*")
@Api("录制相关api")
public class MtRecordingCtrl {
    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private MtRecordingService mtRecordingService;


    @PostMapping("/findMtRecordingByPaged")
    @ApiOperation(value = "MtRecording分页")
    @LogAnnotation(module = "im", recordRequestParam = false)
    public PageResult<MtRecording> findMtRecordingByPaged(@RequestBody PageRequest<MtRecording> pageRequest) {
        return mtRecordingService.findMtRecordingByPaged(pageRequest);
    }

    @PostMapping("/findMtRecording")
    @ApiOperation(value = "MtRecording List")
    @LogAnnotation(module = "im", recordRequestParam = false)
    public Result<List<MtRecording>> findMtRecording(@RequestBody MtRecording imMtRecording) {
        return Result.succeed(mtRecordingService.findMtRecording(imMtRecording));
    }

    @GetMapping("/get/{id}")
    @ApiOperation(value = "获取MtRecording")
    @LogAnnotation(module = "im", recordRequestParam = false)
    public Result get(@PathVariable String id) {
        return Result.succeed(mtRecordingService.getById(id));
    }

    @GetMapping("/get/full/{id}")
    @ApiOperation(value = "获取MtRecording")
    @LogAnnotation(module = "im", recordRequestParam = false)
    public Result getFull(@PathVariable String id) {
        return Result.succeed(mtRecordingService.getMtRecordingFull(id));
    }

    @DeleteMapping("/delete/{id}")
    @ApiOperation(value = "删除录制信息")
    @LogAnnotation(module = "im", recordRequestParam = true)
    public Result delete(@PathVariable String id) {
        return Result.result(mtRecordingService.removeById(id));
    }

    @PostMapping("/addMtRecording")
    @ApiOperation(value = "保存录制信息")
    @LogAnnotation(module = "im", recordRequestParam = true)
    public Result addMtRecording(@RequestBody MtRecordingVo imMtRecording) {
        return Result.result(mtRecordingService.saveMtRecording(imMtRecording));
    }
}
